module.exports = function ($scope, $resource, $modal, toaster, getDate) {

	//查询公示信息列表
	$scope.getList = function(pageNo) {
		$scope.searchform.loading = true;
		var para = {
			'pageNo': pageNo,
			'pageSize': $scope.itemsPerPage,
			'deal': '1',
			'company_code': $scope.searchform.company_code,
			'check_type': $scope.searchform.check_type
		}
		$resource('/api/as/goc/applycheck/getApplyCheckList', {}, {}).save(para, function(res){
            if (res.errcode === 0) {
				$scope.public_list = res.data.results;
				$scope.totalItems = res.data.totalRecord;
				$scope.currentPage = pageNo;
				$scope.searchform.loading = false;
            } else {
                toaster.error({title: '', body: '查询公示信息列表失败'});
            }
        });
	}

	//查询全部已参加出境游的机构列表
	$scope.loadCompanyList = function(){
		$resource('/api/as/goc/companyapply/getCompanyCodeList', {}, {}).save({}, function(res){
			if (res.errcode === 0) {
				$scope.company_list = res.data;
				$scope.company_list.unshift({'company_name': '全部', 'company_code': null});
			}
		});
	}
	
	init();
	function init() {
		$scope.currentPage = 1;			//当前页码
		$scope.itemsPerPage = 10;		//每页显示几条
		$scope.searchform = {};
		$scope.typelist = [
			{'label': '全部', 'value': ''},
			{'label': '出境游团', 'value': '1'},
			{'label': '游客名单', 'value': '2'},
		];
		$scope.loadCompanyList();
		$scope.getList(1);
	}


	$scope.setPublicTime = function(obj){
		var modalInstance = $modal.open({
			template: require('../views/setPublicTime.html'),
			controller: 'setPublicTime',
			size: 'lg',
			resolve: {
				getDate : function(utilservice){
					return utilservice.getDate;
				},
				obj: function () {
					return obj;
				}
			}
		});
		//关闭模态框刷新页面
		modalInstance.result.then(function(result) {
			obj.start_time = result.start_time;
			obj.end_time = result.end_time;
		});
	}


};